[Demo] Modernize TypeScript demos to NodeNext + ES2022#1534
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the TypeScript demo documentation and build configs to align with the package’s modern Node.js ESM/exports setup by switching demos to NodeNext module resolution and ES2022 targets.
Changes:
- Update TypeScript config examples (root README + demo tsconfigs) to
module/moduleResolution: NodeNextandtarget/lib: ES2022. - Remove references to local stub
types/definitions in demo docs (demos now use in-treerclnodejstypings). - Refresh demo READMEs to reflect the new setup and ES2022+ positioning.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| README.md | Modernizes the recommended TS compiler options snippet to NodeNext + ES2022. |
| demo/typescript/topics/tsconfig.json | Switches topics demo TS compilation to NodeNext + ES2022 and removes local typeRoots usage. |
| demo/typescript/topics/README.md | Updates documentation to reflect using in-tree rclnodejs typings (no local stubs). |
| demo/typescript/services/tsconfig.json | Switches services demo TS compilation to NodeNext + ES2022 and removes local typeRoots usage. |
| demo/typescript/services/README.md | Updates docs to reflect using in-tree rclnodejs typings rather than local stub types. |
| demo/typescript/README.md | Updates overview wording from ES2020+ to ES2022+. |
| demo/typescript/actions/tsconfig.json | Switches actions demo TS compilation to NodeNext + ES2022 and removes local typeRoots usage. |
| demo/typescript/actions/README.md | Removes the (now-obsolete) types/ stub types from the folder tree. |
Comments suppressed due to low confidence (1)
demo/typescript/services/tsconfig.json:24
includestill referencestypes/**/*, but there is notypes/directory in this demo. WithrootDir: "./src", including files outsidesrc/would also fail compilation if atypes/folder is added back later. Remove the unused glob sorootDir/includeare consistent.
"typeRoots": ["./node_modules/@types"]
},
"include": [
"src/**/*",
"types/**/*"
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
16
to
19
| "typeRoots": [ | ||
| "./types", | ||
| "./node_modules/@types" | ||
| ] | ||
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
1. ESM migration of
example/(44 files)Converted every CommonJS example to native ESM (
.cjs→.mjs):'use strict', replacedrequire('…/index.js').defaultwithimport rclnodejs from '…/index.js'.main()/.then().catch()into top-levelawait+try/catch..cjs→.mjs, plus the "import rclnodejs from 'rclnodejs'" note).2. ESM migration of demos (3 files)
demo/rosocket/server.cjs→server.mjsdemo/web/javascript/runtime.cjs→runtime.mjsdemo/web/javascript/static.cjs→static.mjs(adds__dirnameshim viafileURLToPath)../../rosocket/index.js,../../../lib/runtime/index.js).demo/rosocket/README.md,demo/web/javascript/README.md, anddemo/web/typescript/server.tscomments.3. demo/typescript modernization (no .cjs→.mjs)
actions/,services/,topics/tsconfig.json:module/moduleResolution→NodeNext,target/lib→ ES2022, removed stale./typestypeRoots.README.md+ per-folder READMEs (ES2022 wording, removed false "local type definitions" claims).4. ESM fix for benchmarks (4 files)
benchmark/rclnodejs/**/*.jsused barerequire()under the root"type": "module"and threwReferenceError: require is not defined. Converted to ESM (import { program } from 'commander',import rclnodejs from '../../../index.js'). Verified against ROS 2 Jazzy: topic + service pairs run with no exceptions.5. CommonJS island fix for jsdoc tooling (1 file)
Added
tools/jsdoc/package.json={"type":"commonjs"}sobuild-index.js,regenerate-published-docs.js, and the jsdoc templatepublish.js(which must keep that exact name and be CJS) load correctly. Without it,npm run docsaborts with "Unable to load template: require is not defined". Verified:npm run docsnow exits 0.6. Root README ESM conversion (
README.md, 13/13 lines)require('rclnodejs')+.init().then()→import rclnodejs from 'rclnodejs'+ top-levelawait.require('rxjs')→import { throttleTime, map } from 'rxjs'.require('rclnodejs')→import rclnodejs from 'rclnodejs'.publisher-example.cjs→publisher-example.mjs.tsconfigsnippet →module: NodeNext,moduleResolution: NodeNext,target: es2022.Fix: #1358